;; e1.22

(define (divides? a b)
  (= (remainder b a) 0))
(define (square x) (* x x))
(define (find-divisor n test-divisor)
  (cond ((> (square test-divisor) n) n)
        ((divides? test-divisor n) test-divisor)
        (else (find-divisor n (+ test-divisor 1)))))
(define (smallest-divisor n)
  (find-divisor n 2))

(define (prime? n)
  (= n (smallest-divisor n)))

(define (report-prime elapsed-time)
    (display " *** ")
    (display elapsed-time))
    (newline)
(define (start-prime-test n start-time)
    (if (prime? n)
        (report-prime (- (current-time) start-time))))
(define (timed-prime-test n)
    (newline)
    (display n)
    (start-prime-test n (current-time)))

(timed-prime-test 12347)
(timed-prime-test 11)
(newline)
